//
//  QZSeeUserPrivacyView.m
//  shortvideoplay
//
//  Created by tikeios_002 on 2024/7/2.
//

#import "QZSeeUserPrivacyView.h"
#import "YYLabel.h"
#import "NSAttributedString+YYText.h"

@implementation QZSeeUserPrivacyView
{
    YYLabel * displayView;
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.backgroundColor = subviewback_black;
        self.layer.cornerRadius = 20;
        self.clipsToBounds = YES;
        
        displayView = [[YYLabel alloc] init];
        displayView.frame = CGRectMake(15, 20, 300, 240);
        displayView.textColor= [UIColor whiteColor];
        displayView.numberOfLines = 0;
        [self addSubview:displayView];
        NSString * tip = @"感谢你信任并使用toke\n当你使用本app前，请务必仔细阅读，充分理解“用户协议”和“隐私政策”各条款，包括但不限于：为你提供服务并保障你的相关信息，以及为你提供的访问、修改、删除和你相关的信息方式。\n\n如你同意";
        NSMutableAttributedString * moreAttr = [[NSMutableAttributedString alloc] initWithString:@"感谢你信任并使用toke\n当你使用本app前，请务必仔细阅读，充分理解“用户协议”和“隐私政策”各条款，包括但不限于：为你提供服务并保障你的相关信息，以及为你提供的访问、修改、删除和你相关的信息方式。\n\n如你同意《用户协议》和《隐私政策》，请点击“同意”开始使用我们的产品和服务。" attributes:@{NSForegroundColorAttributeName : ColorHex_Alpha(@"FFFFFF", 0.88), NSFontAttributeName : Font(15)}];
        
        KWeakSelf
        [moreAttr setTextHighlightRange:NSMakeRange(tip.length, 6) color:MainColor backgroundColor:UIColor.clearColor tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
            //点击
            if(weakSelf.seeUserPrivacyBlock){
                weakSelf.seeUserPrivacyBlock(0);
            }
        }];
        [moreAttr setTextHighlightRange:NSMakeRange(tip.length+7, 6) color:MainColor backgroundColor:UIColor.clearColor tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
            //点击
            if(weakSelf.seeUserPrivacyBlock){
                weakSelf.seeUserPrivacyBlock(1);
            }
        }];
        displayView.attributedText = moreAttr;
        
        
        UIButton * closeButton = [[UIButton alloc]initWithFrame:CGRectMake(15, 280, 140, 42)];
        closeButton.layer.cornerRadius = 8;
        closeButton.layer.borderWidth = 1;
        closeButton.layer.borderColor = [UIColor whiteColor].CGColor;
        closeButton.tag = 2;
        [closeButton setTitle:@"取消" forState:UIControlStateNormal];
        [closeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        closeButton.titleLabel.font = Font(15);
        [closeButton addTarget:self action:@selector(closeTap) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:closeButton];
        
        UIButton * comfitButton = [[UIButton alloc]initWithFrame:CGRectMake(175, 280, 140, 42)];
        comfitButton.layer.cornerRadius = 8;
        comfitButton.backgroundColor = MainColor;
        comfitButton.tag = 3;
        [comfitButton setTitle:@"同意" forState:UIControlStateNormal];
        [comfitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        comfitButton.titleLabel.font = FontMedium(15);
        [comfitButton addTarget:self action:@selector(comfitTap) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:comfitButton];
        
    }
    return self;
}
-(void)closeTap{
    if(self.seeUserPrivacyBlock){
        self.seeUserPrivacyBlock(2);
    }
}
-(void)comfitTap{
    if(self.seeUserPrivacyBlock){
        self.seeUserPrivacyBlock(3);
    }
}
@end
